﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class TestProject : MonoBehaviour
{
    [MenuItem("Assets/Test1")]
    static void Test1() {
        Debug.Log(" test project test1 ");


    }

    [InitializeOnLoadMethod]
    static void InitializeOnLoad()
    {
         
        EditorApplication.projectWindowItemOnGUI += (guid, rect) =>
        {
            //GUI.Button(new Rect(100, 100, 100, 100), "Test1");

            if ( Selection.activeObject != null ) 
            {
                
                string active_guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(Selection.activeObject));

                if ( active_guid == guid && !string.IsNullOrEmpty(active_guid) ) {
                    rect.x = rect.width - 100;
                    rect.width = 100;
                    if (GUI.Button(rect, "delete")) {
                        AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(Selection.activeObject));
                        //Debug.Log( " 删除文件： " + AssetDatabase.GetAssetPath(Selection.activeObject));
                    }
                }
            }

        };
    }

}
